// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: auth.proto

package proto

import (
	"bytes"
	"errors"
	"fmt"
	"net"
	"net/mail"
	"net/url"
	"regexp"
	"sort"
	"strings"
	"time"
	"unicode/utf8"

	"google.golang.org/protobuf/types/known/anypb"
)

// ensure the imports are used
var (
	_ = bytes.MinRead
	_ = errors.New("")
	_ = fmt.Print
	_ = utf8.UTFMax
	_ = (*regexp.Regexp)(nil)
	_ = (*strings.Reader)(nil)
	_ = net.IPv4len
	_ = time.Duration(0)
	_ = (*url.URL)(nil)
	_ = (*mail.Address)(nil)
	_ = anypb.Any{}
	_ = sort.Sort
)

// Validate checks the field values on InputRegisterLogin with the rules
// defined in the proto definition for this message. If any rules are
// violated, the first error encountered is returned, or nil if there are no violations.
func (m *InputRegisterLogin) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on InputRegisterLogin with the rules
// defined in the proto definition for this message. If any rules are
// violated, the result is a list of violation errors wrapped in
// InputRegisterLoginMultiError, or nil if none found.
func (m *InputRegisterLogin) ValidateAll() error {
	return m.validate(true)
}

func (m *InputRegisterLogin) validate(all bool) error {
	if m == nil {
		return nil
	}

	var errors []error

	if err := m._validateEmail(m.GetEmail()); err != nil {
		err = InputRegisterLoginValidationError{
			field:  "Email",
			reason: "value must be a valid email address",
			cause:  err,
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

	if l := utf8.RuneCountInString(m.GetPassword()); l < 6 || l > 150 {
		err := InputRegisterLoginValidationError{
			field:  "Password",
			reason: "value length must be between 6 and 150 runes, inclusive",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

	if len(errors) > 0 {
		return InputRegisterLoginMultiError(errors)
	}

	return nil
}

func (m *InputRegisterLogin) _validateHostname(host string) error {
	s := strings.ToLower(strings.TrimSuffix(host, "."))

	if len(host) > 253 {
		return errors.New("hostname cannot exceed 253 characters")
	}

	for _, part := range strings.Split(s, ".") {
		if l := len(part); l == 0 || l > 63 {
			return errors.New("hostname part must be non-empty and cannot exceed 63 characters")
		}

		if part[0] == '-' {
			return errors.New("hostname parts cannot begin with hyphens")
		}

		if part[len(part)-1] == '-' {
			return errors.New("hostname parts cannot end with hyphens")
		}

		for _, r := range part {
			if (r < 'a' || r > 'z') && (r < '0' || r > '9') && r != '-' {
				return fmt.Errorf("hostname parts can only contain alphanumeric characters or hyphens, got %q", string(r))
			}
		}
	}

	return nil
}

func (m *InputRegisterLogin) _validateEmail(addr string) error {
	a, err := mail.ParseAddress(addr)
	if err != nil {
		return err
	}
	addr = a.Address

	if len(addr) > 254 {
		return errors.New("email addresses cannot exceed 254 characters")
	}

	parts := strings.SplitN(addr, "@", 2)

	if len(parts[0]) > 64 {
		return errors.New("email address local phrase cannot exceed 64 characters")
	}

	return m._validateHostname(parts[1])
}

// InputRegisterLoginMultiError is an error wrapping multiple validation errors
// returned by InputRegisterLogin.ValidateAll() if the designated constraints
// aren't met.
type InputRegisterLoginMultiError []error

// Error returns a concatenation of all the error messages it wraps.
func (m InputRegisterLoginMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m InputRegisterLoginMultiError) AllErrors() []error { return m }

// InputRegisterLoginValidationError is the validation error returned by
// InputRegisterLogin.Validate if the designated constraints aren't met.
type InputRegisterLoginValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e InputRegisterLoginValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e InputRegisterLoginValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e InputRegisterLoginValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e InputRegisterLoginValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e InputRegisterLoginValidationError) ErrorName() string {
	return "InputRegisterLoginValidationError"
}

// Error satisfies the builtin error interface
func (e InputRegisterLoginValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sInputRegisterLogin.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = InputRegisterLoginValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = InputRegisterLoginValidationError{}

// Validate checks the field values on InputLogoutRefresh with the rules
// defined in the proto definition for this message. If any rules are
// violated, the first error encountered is returned, or nil if there are no violations.
func (m *InputLogoutRefresh) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on InputLogoutRefresh with the rules
// defined in the proto definition for this message. If any rules are
// violated, the result is a list of violation errors wrapped in
// InputLogoutRefreshMultiError, or nil if none found.
func (m *InputLogoutRefresh) ValidateAll() error {
	return m.validate(true)
}

func (m *InputLogoutRefresh) validate(all bool) error {
	if m == nil {
		return nil
	}

	var errors []error

	// no validation rules for RefreshToken

	if len(errors) > 0 {
		return InputLogoutRefreshMultiError(errors)
	}

	return nil
}

// InputLogoutRefreshMultiError is an error wrapping multiple validation errors
// returned by InputLogoutRefresh.ValidateAll() if the designated constraints
// aren't met.
type InputLogoutRefreshMultiError []error

// Error returns a concatenation of all the error messages it wraps.
func (m InputLogoutRefreshMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m InputLogoutRefreshMultiError) AllErrors() []error { return m }

// InputLogoutRefreshValidationError is the validation error returned by
// InputLogoutRefresh.Validate if the designated constraints aren't met.
type InputLogoutRefreshValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e InputLogoutRefreshValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e InputLogoutRefreshValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e InputLogoutRefreshValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e InputLogoutRefreshValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e InputLogoutRefreshValidationError) ErrorName() string {
	return "InputLogoutRefreshValidationError"
}

// Error satisfies the builtin error interface
func (e InputLogoutRefreshValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sInputLogoutRefresh.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = InputLogoutRefreshValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = InputLogoutRefreshValidationError{}

// Validate checks the field values on ResponseData with the rules defined in
// the proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *ResponseData) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on ResponseData with the rules defined
// in the proto definition for this message. If any rules are violated, the
// result is a list of violation errors wrapped in ResponseDataMultiError, or
// nil if none found.
func (m *ResponseData) ValidateAll() error {
	return m.validate(true)
}

func (m *ResponseData) validate(all bool) error {
	if m == nil {
		return nil
	}

	var errors []error

	// no validation rules for AccessToken

	// no validation rules for RefreshToken

	// no validation rules for UserId

	if len(errors) > 0 {
		return ResponseDataMultiError(errors)
	}

	return nil
}

// ResponseDataMultiError is an error wrapping multiple validation errors
// returned by ResponseData.ValidateAll() if the designated constraints aren't met.
type ResponseDataMultiError []error

// Error returns a concatenation of all the error messages it wraps.
func (m ResponseDataMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m ResponseDataMultiError) AllErrors() []error { return m }

// ResponseDataValidationError is the validation error returned by
// ResponseData.Validate if the designated constraints aren't met.
type ResponseDataValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e ResponseDataValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e ResponseDataValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e ResponseDataValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e ResponseDataValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e ResponseDataValidationError) ErrorName() string { return "ResponseDataValidationError" }

// Error satisfies the builtin error interface
func (e ResponseDataValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sResponseData.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = ResponseDataValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = ResponseDataValidationError{}

// Validate checks the field values on ResponseLogoutData with the rules
// defined in the proto definition for this message. If any rules are
// violated, the first error encountered is returned, or nil if there are no violations.
func (m *ResponseLogoutData) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on ResponseLogoutData with the rules
// defined in the proto definition for this message. If any rules are
// violated, the result is a list of violation errors wrapped in
// ResponseLogoutDataMultiError, or nil if none found.
func (m *ResponseLogoutData) ValidateAll() error {
	return m.validate(true)
}

func (m *ResponseLogoutData) validate(all bool) error {
	if m == nil {
		return nil
	}

	var errors []error

	// no validation rules for RefreshToken

	if len(errors) > 0 {
		return ResponseLogoutDataMultiError(errors)
	}

	return nil
}

// ResponseLogoutDataMultiError is an error wrapping multiple validation errors
// returned by ResponseLogoutData.ValidateAll() if the designated constraints
// aren't met.
type ResponseLogoutDataMultiError []error

// Error returns a concatenation of all the error messages it wraps.
func (m ResponseLogoutDataMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m ResponseLogoutDataMultiError) AllErrors() []error { return m }

// ResponseLogoutDataValidationError is the validation error returned by
// ResponseLogoutData.Validate if the designated constraints aren't met.
type ResponseLogoutDataValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e ResponseLogoutDataValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e ResponseLogoutDataValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e ResponseLogoutDataValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e ResponseLogoutDataValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e ResponseLogoutDataValidationError) ErrorName() string {
	return "ResponseLogoutDataValidationError"
}

// Error satisfies the builtin error interface
func (e ResponseLogoutDataValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sResponseLogoutData.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = ResponseLogoutDataValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = ResponseLogoutDataValidationError{}
